package com.zjz.mapper;

import com.zjz.pojo.User;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

public class UserMapperImpl extends SqlSessionDaoSupport implements UserMapper{
    // 我们之前所有的操作，在原来都使用sqlSession来执行，，--现在都使用SqlSessionTemplate
/*
    private SqlSessionTemplate sqlSessionTemplate;

    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }
*/

    @Override
    public int addUser(User user) {

        return getSqlSession().getMapper(UserMapper.class).addUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return getSqlSession().getMapper(UserMapper.class).deleteUser(id);
    }

    @Override
    public int updateUser(int id) {
        return 0;
    }

    @Override
    public List<User> selectUser() {
        // 使用钥匙拿到mapper，再拿到按钮
//        return sqlSessionTemplate.getMapper(UserMapper.class).selectUser();

    return getSqlSession().getMapper(UserMapper.class).selectUser();

    }
}
